<template>
  <div class="bg-w">
    <div class="box container" v-if="peopleData">
      <div class="details-title">
        {{ peopleData.worksTitle }}
      </div>
      <div class="head-box" @click="handHead()">
        <div class="head-l">
          <el-image
            class="head-img"
            :src="peopleData.artistPortrait"
            fit="cover"
          />
          <div class="name-box">
            <div class="name">{{ peopleData.author }}</div>
            <div class="post">{{ peopleData.position }}</div>
          </div>
        </div>
        <img class="jiantou" src="@/assets/imgs/jiantou.png" alt="" />
      </div>
      <div class="container al-start j-sb">
        <div class="left">
          <div class="w100">
            <build-el-title-text
              :title="peopleData.modelName1"
            ></build-el-title-text>
          </div>
          <div v-html="peopleData.modelContent1" v-margin-top="'15px'" />
          <div class="w100" v-margin-top="'40px'">
            <build-el-title-text
              :title="peopleData.modelName2"
            ></build-el-title-text>
          </div>
          <div v-html="peopleData.modelContent2" v-margin-top="'15px'" />
        </div>
      </div>
      <!-- <el-button
        @click="handVote"
        class="w100 my-btn-bg"
        v-margin-top="'20px'"
        type="primary"
      ></el-button> -->
      <div @click="handVote" class="w100 my-btn-bg" v-margin-top="'20px'">
        投 票
      </div>
      <div v-margin-top="'30px'"></div>
    </div>
  </div>
</template>
<script>
import buildElBread from '@/components/build-el-bread'
import buildElTitleText from '@/components/build-el-title-text'
import buildElPerviewImgs from '@/components/build-el-perview-imgs'
import buildElHead from '../components/build-el-head'
import JSONData from '@/assets/JSON'
export default {
  components: {
    buildElBread,
    buildElTitleText,
    buildElPerviewImgs,
    buildElHead,
  },
  data() {
    return {
      ...JSONData,
      peopleData: null,
      id: null,
    }
  },
  async created() {
    this.id = this.$route.query.id
    this.init(this.id)
  },

  methods: {
    handHead() {
      // console.log(this.rid)
      if (this.peopleData.recordId) {
        window.open(
          'http://www.cbda1984.com/pc/#/preDetails?recordId=' +
            this.peopleData.recordId
        )
      }
    },
    async handVote() {
      console.log(this.peopleData)
      let res = await this.api.votePc({
        customizeId: 2,
        worksId: this.peopleData.worksId,
      })
      this.$message({
        message: res.content,
        type: 'success',
      })
      console.log(res)
    },
    async init(id) {
      let people = await this.api.selectOneArtistPeople({ worksId: id })
      this.peopleData = people
      console.log(people)
    },
  },
}
</script>
<style lang="less" scoped>
.my-btn-bg {
  color: #fff;
  background-color: #333333;
  border-color: #333333;
  height: 45px;
  border-radius: 6px;
  line-height: 45px;
  text-align: center;
}
.head-box {
  padding: 15px;
  box-sizing: border-box;
  border-radius: 6px;
  background-color: #f7f7f7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  .jiantou {
    width: 8px;
    height: 8px;
  }
  .head-l {
    display: flex;
    text-align: left;
    .head-img {
      width: 48px;
      height: 48px;
      border-radius: 50%;
      margin-right: 8px;
    }
    .name-box {
      .name {
        font-weight: bold;
        color: #312d2d;
        font-size: 15px;
        margin-bottom: 5px;
      }
      .post {
        color: #808080;
        font-size: 13px;
      }
    }
  }
}
.details-title {
  margin-top: 20px;
  font-size: 20px;
  color: #000;
  font-weight: bold;
  margin-bottom: 25px;
}
.right {
  // width: 300px;
  background: #ffffff;
  padding: 32px 20px;
  border-radius: 6px;
  border-radius: 6px;
  .dep {
    font-size: 14px;
    color: #666666;
    letter-spacing: 0;
    text-align: left;
    margin-top: 20px;
  }
}
</style>
